<?php

// 获取前端传过来的用户名和密码
// 查询数据库里是否有一条数据和接收到的用户名和密码完全一致

$name = $_POST['name'];
$pwd = $_POST['pwd'];

$conn = mysqli_connect('localhost', 'root', 'root', '2008');
mysqli_query($conn, "set charset 'utf8'");
mysqli_query($conn, "set character set 'utf8'");

// 写sql语句
$sql = "select * from user where name='$name' and pwd='$pwd'";

// echo $sql; // 输出sql语句复制到数据库工具里执行

$res = mysqli_query($conn, $sql);

// 获取资源长度
$count = mysqli_num_rows($res);

if ($count > 0) {
  echo '登录成功,去<a href="../../index.html">首页</a>';
} else {
  echo '用户名或密码错误';
}


?>